<html>
    <head>
        <style>
            body {
                padding: 0;
                margin: 0;
            }

            #position {
                width: 1px;
                height: 200px;
            }

            .sticky {
                position: sticky;
                top: 100px;
                width: 100%;
                height: 200px;
                background: #0088ff;
            }

            .sticky.b {
                position: fixed;
                top: 0;
                left: 0;
                width: 300px;
                height: 300px;
            }

            #trigger-overflow {
                width: 1px;
                height: 1px;
                position: absolute;
                top: 2000px;
                left: 2000px;
            }

            [data-layout-correct="false"] {
                background: #dd1144 !important;
                opacity: 0.5;
            }
        </style>
    </head>
    <body>
        <div id="position"></div>
        <div class="sticky"></div>
        <div id="trigger-overflow"></div>

        <script type="module" src="/src/imports/projection.js"></script>
        <script type="module" src="/src/imports/script-assert.js"></script>
        <script type="module" src="/src/imports/script-undo.js"></script>
        <script type="module">
            const { createNode } = window.Undo
            const {
                matchViewportBox,
                matchVisibility,
                matchOpacity,
                addPageScroll,
            } = window.Assert
            const { frame } = window.Projection

            const sticky = document.querySelector(".sticky")
            const stickyProjection = createNode(sticky, undefined)

            const stickyOrigin = sticky.getBoundingClientRect()

            stickyProjection.willUpdate()

            sticky.classList.add("b")

            stickyProjection.root.didUpdate()

            setTimeout(() => {
                matchViewportBox(sticky, stickyOrigin)
            }, 50)
        </script>
    </body>
</html>
